#!/usr/bin/python
'''
/*
 * This computer program is the confidential information and proprietary trade
 * secret of VistaraIT LLC.  Possessions and use of this program must  conform
 * strictly to the license agreement between the user and VistaraIT LLC.,  and
 * receipt or possession does not convey any rights to divulge, reproduce,  or
 * allow others to use this program without specific written authorization  of
 * VistaraIT LLC.
 * 
 * Copyright (c) 2014 VistaraIT, Inc. All rights reserved.
 */
'''

import os

DIR_MENU_FILE = '/home/admin/'
DATA_DIR = DIR_MENU_FILE + 'data/'
WORK_DIR = DIR_MENU_FILE + 'work/'
WORK_IFCFG_ETH0 = WORK_DIR + 'interfaces'
WORK_IFCFG_KVMBR0 = WORK_DIR + 'ifcfg-kvmbr0'
WORK_NTP_CONF = WORK_DIR + 'ntp.conf'
NEMSAPP_STOP_CMD = DIR_MENU_FILE + 'bin/menu_stop.sh'
RESET_DB_CMD = DIR_MENU_FILE + 'bin/databasedefaults.sh'
WORK_IFCFG_KVM_ETH0 = '/home/admin/adminui/admin/templates/config/ifcfg-kvm-eth0'
VIRT_ETH0_TEMP = '/home/admin/adminui/admin/templates/config/virtual-ifcfg-eth0'

SYSCONFIG_IFCFG_ETH0 = '/etc/network/interfaces'
SYSCONFIG_IFCFG_KVMBR0 = '/etc/sysconfig/network-scripts/ifcfg-kvmbr0'
SYSCONFIG_VIRT_ETH0 = '/etc/sysconfig/network-scripts/ifcfg-eth0:0'
ETC_NTP_CONF = '/etc/ntp.conf'
URL_WHATISMYIP = 'http://www.whatismyip.com/automation/n09230945.asp'
BRIDGE_DEFAULT_FILE = '/etc/libvirt/qemu/networks/default.xml'
BRIDGE_WORK_FILE = WORK_DIR + 'default.xml'
ETH1_DEVICE_CHECK_FILE = '/sys/class/net/eth1/device'

#password check commands
APPLIANCE_PWD_VAL_COMMAND = DIR_MENU_FILE + 'bin/passcheck.sh'
APPLIANCE_CHG_PWD_COMMAND = DIR_MENU_FILE + 'bin/chgpasswd.sh'
APPLIANCE_RST_PWD_COMMAND = DIR_MENU_FILE + 'bin/rstpasswd.sh'

#datetime functions
APPLIANCE_SET_TIMEZONE = DIR_MENU_FILE + 'bin/menu_timezone.sh'
APPLIANCE_MENU_SET_TIME = DIR_MENU_FILE + 'bin/menu_set_time.sh'

#system commands
CMD_CP = '/bin/cp'
CMD_SUDO = '/usr/bin/sudo'

CMD_CHECK_BRIDGE = CMD_SUDO + ' /usr/sbin/brctl show | grep kvmbr0'
CMD_CHECK_KVM = CMD_SUDO + " /sbin/lsmod | grep kvm"
CMD_HOST_NAME = CMD_SUDO + ' ' + '/bin/hostname'
CMD_SET_DATE =  CMD_SUDO + ' ' + "/bin/date +'%T %D' -s"

CMD_CP_IFCFG_ETH0 = CMD_SUDO + ' ' + CMD_CP + ' -f ' +  WORK_IFCFG_ETH0 + ' ' + SYSCONFIG_IFCFG_ETH0
CMD_CP_VIRT_ETH0 = CMD_SUDO + ' ' + CMD_CP + ' -f ' +  VIRT_ETH0_TEMP + ' ' + SYSCONFIG_VIRT_ETH0
CMD_CP_NTP_CONF = CMD_SUDO + ' ' + CMD_CP + ' -f ' +  WORK_NTP_CONF + ' ' + ETC_NTP_CONF
CMD_NETWORK_RESTART = CMD_SUDO + ' ' + '/etc/init.d/networking restart'

CMD_NTP_STOP = CMD_SUDO + ' ' + '/home/admin/bin/servicemonit ntp stop'
CMD_NTP_START = CMD_SUDO + ' ' + '/home/admin/bin/servicemonit ntp start'
CMD_NTP_STATUS = CMD_SUDO + ' ' + '/home/admin/bin/servicemonit ntp status | grep running'
CMD_NTP_SYNC = CMD_SUDO + ' ' + '/usr/sbin/ntpdate -u '

CMD_NTP_SYNC_STATUS = '/home/admin/bin/ntpcheck.sh'
CMD_ENCRYPT_LOGS = '/home/admin/bin/encDecScript.sh encrypt '
CMD_DECRYPT_FILE = '/home/admin/bin/encDecScript.sh decrypt '
CMD_GEN_BANNER = CMD_SUDO + ' /bin/sh /home/admin/bin/gen_login_banner.sh'
CMD_DMIDECODE_STRING = CMD_SUDO + ' /usr/sbin/dmidecode -s '
CMD_DMIDECODE = CMD_SUDO + ' /usr/sbin/dmidecode '
CMD_LSHW = CMD_SUDO + ' /usr/bin/lshw '

# /etc/resolv.conf
WORK_RESOLV_CONF = WORK_DIR + 'resolv.conf'
ETC_RESOLV_CONF = '/etc/resolv.conf'
CMD_CP_RESOLV_CONF = CMD_SUDO + ' ' + CMD_CP + ' -f ' + WORK_RESOLV_CONF + ' ' + ETC_RESOLV_CONF

#/etc/sysconfig/network
WORK_NETWORK = WORK_DIR + 'network'
ETC_SYSCONFIG_NETWORK = '/etc/sysconfig/network'
CMD_CP_NETWORK = CMD_SUDO + ' ' + CMD_CP + ' -f ' + WORK_NETWORK + ' ' + ETC_SYSCONFIG_NETWORK

#/etc/hosts
WORK_HOSTS = WORK_DIR + 'hosts'
ETC_HOSTS = '/etc/hosts'
CMD_CP_HOSTS = CMD_SUDO + ' ' + CMD_CP + ' -f ' + WORK_HOSTS + ' ' + ETC_HOSTS
WORK_HOSTNAME = WORK_DIR + 'hostname'
ETC_HOSTNAME = '/etc/hostname'
CMD_CP_HOSTNAME = CMD_SUDO + ' ' + CMD_CP + ' -f ' + WORK_HOSTNAME + ' ' + ETC_HOSTNAME
CMD_HOSTNAME_RESTART = CMD_SUDO + ' ' + 'service hostname restart'

## For Registration and Automatic Upgrades
URL_REGISTRATION = '/saregandlicdownload.do?action=registration'
#URL_VPMG_LICENSE = '/saregandlicdownload.do?action=downloadLatestSALicense'
#LICENSE_INSTALL_STATUS = '/saregandlicdownload.do?action=licenseInstallStatus'
#URL_LICENSE_DOWNLOAD = '/saregandlicdownload.do?action=downloadSALicense'
URL_TUNNEL_REQ = '/sarequest.do?action=processSARequest'
URL_SUPPORT_TOKEN = 'checkConnection'
URL_SUPPORT_PING = '/sccping.do?action=ping&token=' + URL_SUPPORT_TOKEN

## Software Updates
FW_DOWNLOADS_DIR = "/var/fw/downloads/"
FW_DECRYPT_DIR = "/var/fw/decrypted/"
UPGRADES_WORK_DIR = "/var/fw"
CONN_CLIENT_CERT = "/var/fw/cert/fws_client.pem"
CONN_KEY_CERT = "/var/fw/cert/fws_key.pem"
FW_VERSIONS = "/var/fw/versionInfo"
UPGRADES_LOGFILE = "/var/fw/upgrades.log"
UPGRADES_LOCKFILE = "/var/fw/fwinstall.lck"
CHECK_UPDATES_ACTION = 'CheckUpdates'
MAINTENANCE_MODE_ACTION = 'MaintenanceRequest'

## Log Files
APPLIANCE_LOG_FILE = "/home/admin/logs/adminui.log"
DEBUG_LOG_FILE = "/home/admin/logs/debug.log"
ADMIN_LOGS_DIR = "/home/admin/logs/"

VAR_MESSAGE_FILE = "/var/log/messages*"
VAR_SECURE_FILE = "/var/log/secure*"
VAR_BOOT_FILE = "/var/log/boot.log*"
VAR_SYSLOG_FILE = "/var/log/syslog*"
VAR_LOG_FILES = "/var/log/*.log"

NEMS_LOGS_DIR = "/var/log/app"
NGINX_LOG_DIR = "/usr/local/nginx/logs/"

AUTO_REG_SUCCESS = 'Appliance Registered Successfully.'
AUTO_REG_ALREADY_SUCCESS = 'Appliance Already Registered.'
AUTO_SCH_NOUPDATES = 'No updates are available.'

SSH_PATH = '/usr/local/ssh/bin/ssh'
TUNNEL_SSH_KEY = '/home/admin/data/tunnel_key'
TUNNEL_TEMP_FILE = "/home/admin/work/tunnel_temp"
LB_PROPERTY_FILE = '/nems/conf/LBProperties.properties'
LBPROPERTY_WORK_FILE = '/home/admin/work/LBProperties.properties'
TUNNEL_ACTION_GETPORTS = 'GetTunnelPorts'
TUNNEL_ACTION_GETSUCCESS = 'SAEvent'
UNREGISTRATION_ACTION = 'SADeregistrationRequest'
TUNNEL_LOCK_FILE = "/var/lock/tunnelreq.lck"
NSG_HW_INFO_FILE = "/etc/nsg/applianceHardwareInfo"
VG_REGISTRATION_FILE = "/etc/nsg/regInfo"

NSG_OPENSTACK_INFO_FILE = "/etc/nsg/openstack_controller"
UNKNOWN_MODEL_TAG = "SGUNK"

TEST_PUBLIC_SERVER_NAME = "google.com"
TEST_PUBLIC_SERVER_PORT = "443"

#discovery
JSVC_SERVICE_NAME = "neprobe"

DISCOVERY_CFG_WORK = "/home/admin/work/neprobe.conf"
DISCOVERY_CFG_DEST = "/nems/neprobe/conf/neprobe.conf"
NEMON_CFG_WORK = "/home/admin/work/clientcode.cfg"
NEMON_CFG_DEST = "/nems/nagios/clientcode/clientcode.cfg"
NODEMGR_CFG_WORK = "/home/admin/work/nodeMgr"
NODEMGR_CFG_DEST = "/home/admin/data/nodeMgr"
NDA_CFG_WORK = "/home/admin/work/sa.properties"
NDA_CFG_DEST = "/nems/conf/sa.properties"
MONITRC_CFG_WORK = "/home/admin/work/monitrc"
MONITRC_CFG_DEST = "/etc/monit/monitrc"
MON_CFG_WORK = "/home/admin/work/monitoring.properties"
MON_CFG_DEST = "/etc/nsg/monitoring.properties"
DHCP_CFG_WORK = "/home/admin/work/dhcpd.conf"
DHCP_CFG_DEST = "/etc/dhcp3/dhcpd.conf" if os.path.isfile('/etc/dhcp3/dhcpd.conf') else "/etc/dhcp/dhcpd.conf"
DHCP_INIT_SERVICE = "dhcp3-server" if os.path.isfile('/etc/init.d/dhcp3-server') else "isc-dhcp-server"
MONITRC_CFG_DIR="/etc/monit/conf.d/"

BDRCORE_DOMAIN_NAME="BDRCORE"
BDRCORE_CONFIG_FILE="/tmp/bdrcore_config"
BDRCORE_DISK_PATH="/data/vmfs/wincore.img"

#PXE
PXE_DB_FILE = '/var/lib/sqlite/nsg.db'
PXE_FILES = '/home/admin/adminui/admin/pxe/'
FTP_PATH = '/data/ftproot/'
PXE_SCRIPTS_PATH = PXE_FILES + 'scripts/'
PXE_TEMPLATES_PATH = PXE_FILES + 'templates/'
PXE_CAT_TEMPLATES_PATH = PXE_FILES + 'pxeconfig/'
PXE_LINUX_CFG_PATH = FTP_PATH + 'pxelinux.cfg/'
PXE_LINUX_AUTO_CFG_PATH = FTP_PATH + 'autoconfigs/'

#OpenStack
INSTALL_CONTROLLER = "/home/admin/adminui/admin/openstack/InstallController.sh"

#INFO MESSAGES
FLOATING_RANGE_IP_INFO = "Public IP range.This is required for the the virtual machines to expose the services. A network and a mask should be entered here. Example: 192.168.1.64/28 ."
FIXED_RANGE_IP_INFO = "Range of internal IP. IP addresses from this range will be assigned to Virtual machines. A network and a mask should be entered here. Example: 192.168.2.64/28 ."
HOST_IN_NETWORK = "Number of host in each private subnet."
